// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)

#ifndef _ARCHIVER_H
#define _ARCHIVER_H

#include "../common.h"
#include "../details/os.h"

namespace spdlog 
{
    namespace archive
    {

        //Archive error handler callback function type
        using archive_err_handler = std::function<void(const std::size_t err_code, const std::string &err_msg)>;

        /*
        Log File Archiver Class Uses abstract interface encapsulation method, similar to Windows COM programming techniques
        */
        class archiver 
        {
        public:
            archiver() = default;
            virtual ~archiver() = default;

            archiver(const archiver&) = delete; // disable copy constructor
            archiver(archiver&&) = delete;  // disable move constructor

            archiver& operator=(const archiver&) = delete; // disable copy assignment
            archiver& operator=(archiver&&) = delete;   // disable move assignment

            virtual bool archive_file(const filename_t& target_file) = 0;
            virtual std::size_t get_archived_files()const = 0;
            virtual std::size_t get_archived_bytes()const = 0;
            virtual std::size_t get_file_size() = 0;
        };
    
        namespace zip
        {
            /*
            level: compression level -1; 0; 1; 9 (-1=default, 0=no compression, 1=best speed, 9=best compression)
            cache_size: cache size for compression buffer, default 32*1024=32kb
            */
            archiver* create_zip_archiver(const filename_t& file_name, const int level=-1, const std::size_t cache_size=1024*32, const archive_err_handler& err_func=nullptr);

            /*
            Although the deleter function is provided, if smart pointers are used for management, this deleter function may not be needed because the internal automatic destruction of smart pointers also uses the delete keyword, just like this deleter.
             */
            void destroy_zip_archiver(archiver* archiver_ptr);
        }   // namespace zip

    }   // namespace archiver
}   // namespace spdlog

#include "zip_archiver-inl.h"

#endif // _ARCHIVER_H